import request from '@/utils/request'

export default {
    getAllSuppliersMessage(){
        const req = request({
            method: 'get',
            url: '/dgut/getAllSupplierMessage'
        })
        return req;
    },
    deleteOneSupplier(sid){
        const req = request({
            method: 'delete',
            url: '/dgut/deleteOneSupplierMessage',
            params:{
                sid
            }
        })
        return req;
    },
    editOneSupplier(Message){
        const req = request({
            method: 'put',
            url: '/dgut/updateOneSupplierMessage',
            params:{
                sid: Message.sid,
                sphone: Message.sphone,
                sname: Message.sname,
                saddress: Message.saddress
            }
        })
        return req;
    },
    getOneSupplier(sid){
        const req = request({
            method: 'get',
            url: '/dgut/getSupplierMessageById',
            params: {
                sid
            }
        })
        return req;
    },
    addOneSupplier(Message) {
        console.log(Message);
        const req = request({
            method: 'post',
            url: '/dgut/addOneSupplierMessage',
            params: {
                sphone: Message.sphone,
                sname: Message.sname,
                smaterial: Message.smaterial,
                sprice: Message.sprice,
                saddress: Message.saddress,
                sendtime: Message.sendtime
            }
        })
        return req;
    },
    search(searchMap){
        if (searchMap.sid != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getSupplierMessageById',
                params: {
                    sid:searchMap.sid
                }
            })
            return req;
        } else if (searchMap.sname != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getSupplierMessageByName',
                params: {
                    sname:searchMap.sname
                }
            })
            return req;
        } else if (searchMap.sphone != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getSupplierMessageByPhone',
                params: {
                    sphone:searchMap.sphone
                }
            })
            return req;
        } else if (searchMap.smaterial != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getSupplierMessageByMaterial',
                params: {
                    smaterial:searchMap.smaterial
                }
            })
            return req;
        } else if (searchMap.saddress != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getSupplierMessageByAddress',
                params: {
                    saddress:searchMap.saddress
                }
            })
            return req;
        }else {
            const req = request({
                method: 'get',
                url: '/dgut/getAllSupplierMessage'
            })
            return req;
        }
    }
}